/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package integracion;

import java.io.Serializable;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 *
 * @author Jonatan Elias
 */
public class DaoGenericoAbstracto<T, ID extends Serializable> extends HibernateDaoSupport {

    public T findById(Class clase, ID id){
        return (T)getHibernateTemplate().load(clase, id);
    }

    public T getById(Class clase, ID id){
        return (T)getHibernateTemplate().get(clase, id);
    }

    public List<T> findAll(Class clase){
        return getHibernateTemplate().find("From "+clase.getName());
    }

    public ID save(T t){
        return (ID)getHibernateTemplate().save(t);
    }

    public void update(T t){
        getHibernateTemplate().update(t);
    }

    public void delete(T t){
        getHibernateTemplate().delete(t);
    }
}
